package com.nativetalk.service.teacher.delete;

import com.nativetalk.base.RetInfo;
import com.nativetalk.bean.teacher.TdNtTeacherResult;
import com.nativetalk.common.ValidationMessages;
import com.nativetalk.common.util.MemcachedUtils;
import com.nativetalk.dao.TdNtTeacherDao;
import com.nativetalk.service.teacher.search.TeacherSearchService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by wuyuanhui on 16/3/3.
 */
@Service
public class TeacherDeleteServiceImpl implements  TeacherDeleteService {
    private static Logger logger = Logger.getLogger(TeacherDeleteServiceImpl.class);
    @Resource
    private TdNtTeacherDao tdNtTeacherDao;
    @Override
    public RetInfo deleteTeacherEmail(TdNtTeacherResult tdNtTeacherResult) {
        String logInfo = this.getClass().getName() + ":deleteTeacherEmail:";
        logger.info("======" + logInfo + "begin======");
        RetInfo retInfo = new RetInfo();
        try {
            tdNtTeacherResult.setTea_email("delete@waijiaojun.com");
            tdNtTeacherDao.deleteTdNtTeacherEmail(tdNtTeacherResult);
            retInfo.setMark(ValidationMessages.getValue("MARKYES"));
            retInfo.setTip(ValidationMessages.getValue("TEACHER.UPDATE.SUCCESS"));
            MemcachedUtils.delete(tdNtTeacherResult.getToken());
        } catch (Exception e) {
            retInfo.setMark(ValidationMessages.getValue("MARKERROR"));
            retInfo.setTip(ValidationMessages.getValue("TIPERROR"));
            logger.error(e.getMessage(),e);
        }
        logger.info("======" + logInfo + "end======");
        return retInfo;
    }
}
